package com.example.demo.controller;

import com.example.demo.bean.Medical;
import com.example.demo.sevice.MedicalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("/medica")
public class MedicalController {
    @Autowired
    private MedicalService medicalService;

    /*查询*/
    @RequestMapping("/med")
    public List<Medical> medicals() {
        System.out.println(medicalService);
        return medicalService.medical();
    }

    //*新增*//
    @RequestMapping("/add")
    public void addMedical(@RequestParam("type") String type) {
        System.out.println(type);
        medicalService.addMedical(type);
    }

    //*删除*//
    @DeleteMapping("/del")
    public void deleteMedical(@RequestParam("type") String medicalId) {
        medicalService.deleteMedical(medicalId);
        System.out.println(medicalId);
    }

    //*修改*//
    @PostMapping("/upd")
    public void updateMedical(Medical medical) {
        medicalService.updateMedical(medical);
        System.out.println(medical);
    }
}
